const express = require( 'express' );
const router = express.Router();

let logger = require( "../../../../utils/utils.logger" );
const tools = require( "../../../../utils/utils.tools" );
const db = require( "../../../../models" );

const sequelize = db.sequelize;
const {
    Op
} = require( "sequelize" );
const information = require( "../../../../controllers/information.controller" );
/**
 * 获取个人信息数据
 * @route GET /api/public/personal/information
 * @group 获取个人信息 - list
 * @returns {object} 200 - 请求返回正确
 * @returns {object} 500 - 请求返回错误
 * @returns {Error}  default - Unexpected error
 */
router.get( "/", function ( req, res ) {
    
    let clientIp = req.headers[ 'x-forwarded-for' ] ||
        req.connection.remoteAddress ||
        req.socket.remoteAddress ||
        req.connection.socket.remoteAddress;
    logger.info( `【IP】${clientIp}【获取资历数据】 ` )
    information.getInformation( ( data, err ) => {
        if ( err ) return res.sendResult( null, 401, err )
        let dt = data.data[0]
        let obj = {
            "name": dt.name,
            "post": dt.post,
            "motto": dt.motto,
            "workYears": dt.workYears,
            "projectItems": dt.projectItems,
            "companyNum": dt.companyNum,
            "head": dt.head,
            "phone": dt.phone,
            "email": dt.email,
            "QQ": dt.QQ,
            "position": dt.position,
            "age": dt.age,
            "birthDate": dt.birthDate,
            "school": dt.school,
            "major": dt.major,
            "education": dt.education,
            "selfIntroduction": dt.selfIntroduction
        }
   
        res.send( obj, 200, '获取数据成功' )
    } )


} );
module.exports = router;